<?php
$currencyMark = text::get('currency.mark-' . ViregWizardData::$CURRENCY_CODE);

/* Seminar */
echo '<h2>' . text::getEscaped('viregWizard.seminar') . '</h2>';
echo '<table class="displayTable">';
echo '<tbody>';
echo '<tr><th><label>' . text::getEscaped('viregWizard.seminarName') . '</label></th><td>';
if ($renderedInAdminSpace) {
	echo html::moreInfoPopup('/admin/viSeminar/display?id=' . $viSeminar['id'], $viSeminar['name']);
}
else {
	echo html::specialchars($viSeminar['name']);
}
echo ', ', format::date($viSeminar['begin_date']) . ' - ' . format::date($viSeminar['end_date']);
echo '</td></tr>';
echo '<tr><th><label>' . text::getEscaped('viregWizard.seminarDescription') . '</label></th><td>' . format::longText($viSeminar['description']) . '</td></tr>';
echo '<tr><th><label>' . text::getEscaped('viSeminar.course_fee') . '</label></th><td><span class="registrationPrice">' . format::decimal($optionsForm['course_fee']) . ' ' . $currencyMark . '</span></td></tr>';
if ($optionsForm['extra_discount']) {
	echo '<tr><th><label>' . text::getEscaped('viRegistration.extra_discount') . '</label></th><td><span class="registrationPrice">' . format::decimal($optionsForm['extra_discount']) . ' ' . $currencyMark . '</span></td></tr>';
}
echo '</tbody>';
echo '</table>';

/* Accomodation type */
echo '<h2>' . text::getEscaped('viregWizard.accomodationTypes') . '</h2>';
echo '<table class="displayTable">';
echo '<tbody>';
echo '<tr><th><label>' . text::getEscaped('viRegistration.night_count') . '</label></th><td>' . $optionsForm['night_count'] . '</td></tr>';
echo '<tr><th><label>' . $optionsForm['viAccomodationType']['name'] . '</label></th><td><span class="registrationPrice">' . format::decimal($optionsForm['accomodation_price']) . ' ' . $currencyMark . '</span></td></tr>';
echo '</tbody>';
echo '</table>';

/* Meals */
$mealsForm = new View('/user/viregWizard/fragments/mealsForm');
$mealsForm->set('displayOnly', TRUE);
$mealsForm->set('optionsForm', $optionsForm);
$mealsForm->render(true);

/* Prices and discounts */
if ($optionsForm['social_discount_applied'] || $registration['bank_payment_discount']) {
	echo '<h2>' . text::getEscaped('viregWizard.discounts') . '</h2>';
	echo '<ul>';
	if ($optionsForm['social_discount_applied']) {
		echo '<li>';
		echo text::getEscaped('viregWizard.socialDiscount') .
				' <span class="registrationPrice">' . format::decimal($viSeminar['prices-' . ViregWizardData::$CURRENCY_CODE]['social_discount']) . ' ' . $currencyMark . '</span>';
		echo '</li>';
	}
	if ($registration['bank_payment_discount']) {
		echo '<li>';
		echo text::getEscaped('viSeminar-bank_payment_discount') .
				' <span class="registrationPrice">' . format::decimal($registration['bank_payment_discount']) . ' ' . $currencyMark . '</span>';
		echo '</li>';
	}
	echo '</ul>';
}

/* Payment type */
$paymentTypeBlockClass = '';
if ($renderedInAdminSpace) {
	$paymentTypeBlockClass = html::printCollapsableBlockHeader('viregWizard.payment', FALSE, NULL, 'paymentTypeBlock');
}
else {
	echo '<h2>' . text::getEscaped('viregWizard.payment') . '</h2>';
}
echo text::getEscaped('viregWizard.paymentType-' . $paymentTypeForm['payment_type']);

echo '<div id="paymentTypeBlock" class="' . $paymentTypeBlockClass . '">';
if ($paymentTypeForm['payment_type'] == 'bank') {
	echo '<p>' . text::getEscaped('viregWizard.paymentInfo-bank') . '</p>';
	echo '<table class="displayTable">';
	echo '<tbody>';

	echo '<tr>';
	echo '<th><label>' . text::getEscaped('bankAccount.name') . '</label></th>';
	echo '<td>';
	if ($renderedInAdminSpace) {
		echo html::moreInfoPopup('/admin/bankAccount/display?id=' . $viSeminar['bankAccount']['id'], $viSeminar['bankAccount']['name']);
	}
	else {
		echo $viSeminar['bankAccount']['name'];
	}
	echo '</td>';
	echo '</tr>';

	$accountProperties = array('bank_name', 'number', 'bank_number', 'iban', 'swift');
	foreach ($accountProperties as $property) {
		echo '<tr>';
		echo '<th><label>' . text::getEscaped('bankAccount.' . $property) . '</label></th>';
		echo '<td>' . $viSeminar['bankAccount'][$property] . '</td>';
		echo '</tr>';
	}
	echo '<tr>';
	echo '<th><label>' . text::getEscaped('viSeminar.variable_symbol') . '</label></th>';
	echo '<td>' . $viSeminar['variable_symbol'] . '</td>';
	echo '</tr>';
	if ($registration) {
		echo '<tr>';
		echo '<th><label>' . text::getEscaped('myRegistration.specific_symbol') . '</label></th>';
		echo '<td>' . $registration['id'] . '</td>';
		echo '</tr>';
	}

	// This is already writen in the discounts parts
// 	if ($bankPaymentDiscount) {
// 		echo '<tr>';
// 		echo '<th><label>' . text::getEscaped('viSeminar.bank_payment_discount') . '</label></th>';
// 		echo '<td><span class="registrationPrice">' . format::price(-1 * $bankPaymentDiscount, ViregWizardData::$CURRENCY_CODE) . '</span></td>';
// 		echo '</tr>';
// 	}

	echo '</tbody>';
	echo '</table>';
}
else {
	echo '<p>' . text::getEscaped('viregWizard.paymentInfo-cash') . '</p>';
}
echo '</div>';

/* Notes */
if ($paymentTypeForm['notes']) {
	echo '<h2>' . text::getEscaped('viregWizard.notes') . '</h2>';
	// echo '<p class="description">' . text::getEscaped('viregWizard.notes-desc') . '</p>';
	echo format::longText($paymentTypeForm['notes']);
}

/* Total price */
echo '<h2>' . text::getEscaped('viregWizard.totalPrice') . '</h2>';
echo '<span class="registrationPrice">' . format::decimal($optionsForm['total_price'] - $bankPaymentDiscountHeight) . ' ' . $currencyMark . '</span>';